//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#include "LigandEpitopeAlignment.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <fstream>
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#define LENGTHLINE 1000
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
using namespace std;
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
LigandEpitopeAlignment::LigandEpitopeAlignment(): lingoSim(0.0),
                                                  highEpitopeAlignment(0.0),
                                                  averageEpitopeAlignment(0.0),
                                                  error(0.0) {
  this->ligandName1 = new String ();
  this->ligandName2 = new String ();
  this->toString    = new String ();

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
LigandEpitopeAlignment::LigandEpitopeAlignment(const LigandEpitopeAlignment& ligandEpitopeAlignment) {
  
  this->ligandName1             = new String (ligandEpitopeAlignment.ligandName1);
  this->ligandName2             = new String (ligandEpitopeAlignment.ligandName2);

  this->lingoSim                = ligandEpitopeAlignment.lingoSim;
  this->highEpitopeAlignment    = ligandEpitopeAlignment.highEpitopeAlignment;
  this->averageEpitopeAlignment = ligandEpitopeAlignment.averageEpitopeAlignment;
  this->error                   = ligandEpitopeAlignment.error;
    
  this->toString                = new String ();
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
LigandEpitopeAlignment::LigandEpitopeAlignment(const LigandEpitopeAlignment* ligandEpitopeAlignment) {
  
  this->ligandName1             = new String (ligandEpitopeAlignment->ligandName1);
  this->ligandName2             = new String (ligandEpitopeAlignment->ligandName2);

  this->lingoSim                = ligandEpitopeAlignment->lingoSim;
  this->highEpitopeAlignment    = ligandEpitopeAlignment->highEpitopeAlignment;
  this->averageEpitopeAlignment = ligandEpitopeAlignment->averageEpitopeAlignment;
  this->error                   = ligandEpitopeAlignment->error;
    
  this->toString                = new String ();
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
LigandEpitopeAlignment::~LigandEpitopeAlignment() {
  
  if (this->ligandName1) delete this->ligandName1;
  if (this->ligandName2) delete this->ligandName2;
  if (this->toString)    delete this->toString;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
String* LigandEpitopeAlignment::LigandName1 (String* ligandName1) {
  
  if (ligandName1) this->ligandName1->In(ligandName1);
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
String* LigandEpitopeAlignment::LigandName2 (String* ligandName2) {
  
  if (ligandName2) this->ligandName2->In(ligandName2);
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void LigandEpitopeAlignment::LingoSim (double lingoSim) {
  
  this->lingoSim = lingoSim;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void LigandEpitopeAlignment::HighEpitopeAlignment (double highEpitopeAlignment) {
  
  this->highEpitopeAlignment = highEpitopeAlignment;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void LigandEpitopeAlignment::AverageEpitopeAlignment (double averageEpitopeAlignment) {
  
  this->averageEpitopeAlignment = averageEpitopeAlignment;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void LigandEpitopeAlignment::Error (double error) {
  
  this->error = error;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
String* LigandEpitopeAlignment::LigandName1 (void) {
  
  return this->ligandName1;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
String* LigandEpitopeAlignment::LigandName2 (void) {
  
  return this->ligandName2;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
double LigandEpitopeAlignment::LingoSim (void) {
  
  return this->lingoSim;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
double LigandEpitopeAlignment::HighEpitopeAlignment (void) {
  
  return this->highEpitopeAlignment;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
double LigandEpitopeAlignment::AverageEpitopeAlignment (void) {
  
  return this->averageEpitopeAlignment;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
double LigandEpitopeAlignment::Error (void) {
  
  return this->error;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
bool LigandEpitopeAlignment::LoadData (String* data) {
  
  if (!data || !data->Length()) return false;
  
  char* part = NULL;
  
  part = strtok(data->Out(), " \t\r\n"); if (part) this->ligandName1->In(part);                else return false;
  part = strtok(NULL, " \t\r\n");        if (part) this->ligandName2->In(part);                else return false;
  part = strtok(NULL, " \t\r\n");        if (part) this->lingoSim                = atof(part); else return false;
  part = strtok(NULL, " \t\r\n");        if (part) this->highEpitopeAlignment    = atof(part); else return false;
  part = strtok(NULL, " \t\r\n");        if (part) this->averageEpitopeAlignment = atof(part); else return false;
  part = strtok(NULL, " \t\r\n");        if (part) this->error                   = atof(part); else return false;
  
  return true;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
bool LigandEpitopeAlignment::LoadData (char* data) {
  
  if (!data) return false;
  
  String dataString;
  dataString.In(data);
  
  return this->LoadData(&dataString);
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
String* LigandEpitopeAlignment::ToString (void) {
  
  this->toString->In(" ");
  
  char buffer [LENGTHLINE];
  
  sprintf(buffer, " %s   %s %5f %5f %5f %f\0", this->ligandName1->Out(),
                                               this->ligandName2->Out(),
                                               this->lingoSim,
                                               this->highEpitopeAlignment,
                                               this->averageEpitopeAlignment,
                                               this->error);
  
  this->toString->Add(buffer);
  
  return this->toString;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
LigandEpitopeAlignment  LigandEpitopeAlignment::operator= (const LigandEpitopeAlignment& ligandEpitopeAlignment) {
  
  this->ligandName1->In(ligandEpitopeAlignment.ligandName1);
  this->ligandName2->In(ligandEpitopeAlignment.ligandName2);

  this->lingoSim                = ligandEpitopeAlignment.lingoSim;
  this->highEpitopeAlignment    = ligandEpitopeAlignment.highEpitopeAlignment;
  this->averageEpitopeAlignment = ligandEpitopeAlignment.averageEpitopeAlignment;
  this->error                   = ligandEpitopeAlignment.error;
  
  return *this;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//

